//
//  PaiZhuoXuanXiang.m
//  HallView
//
//  Created by Lv Changye on 11-7-21.
//  Copyright 2011年 139me. All rights reserved.
//

#import "PaiZhuoXuanXiang.h"


@implementation PaiZhuoXuanXiang
@synthesize roomsort;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
//    [zuoweiBtn release];
//    [suduBtn release];
//    [guibinBtn release];
//    [yimanBtn release];
    [scroll release];
    
//    [wuzuo release];
//    [jiuzuo release];
//    [renhezuo release];
    
//    [putongsu release];
//    [kuaisu release];
//    [renhesu release];
    
    
//    [noguibinzhuo release];
//    [guibinzhuo release];
//    [renhezhuo release];
    
//    [yincang release];
//    [noyincang release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void) setRoomsort:(RoomSort) rs
{
	roomsort = rs;	
	
	//设置显示
	choumadaxiao.contentSize=CGSizeMake(95*(rs.num + 2), 31);
    
	for (int i=0; i<rs.num; i++) {
        UIButton *label=[UIButton buttonWithType:UIButtonTypeCustom];
        label.frame=CGRectMake(95*(i+1), 0, 95, 31);
        label.tag=i+1;
        
        //        switch (i) {
        //            case 1:
        //                [label setTitle:@"$1/2" forState:UIControlStateNormal];
        //                break;
        //            case 2:
        //                [label setTitle:@"$5/10" forState:UIControlStateNormal];
        //                break;
        //            case 3:
        //                [label setTitle:@"$25/50" forState:UIControlStateNormal];
        //                break;
        //            case 4:
        //                [label setTitle:@"$100/200" forState:UIControlStateNormal];
        //                break;
        //            case 5:
        //                [label setTitle:@"$500/1千" forState:UIControlStateNormal];
        //                break;
        //            case 6:
        //                [label setTitle:@"$2.5千/5千" forState:UIControlStateNormal];
        //                break;
        //            case 7:
        //                [label setTitle:@"$1万/2万" forState:UIControlStateNormal];
        //                break;
        //            case 8:
        //                [label setTitle:@"$5万/10万" forState:UIControlStateNormal];
        //                break;
        //            case 9:
        //                [label setTitle:@"$25万/50万" forState:UIControlStateNormal];
        //                break;
        //            case 10:
        //                [label setTitle:@"$50万/100万" forState:UIControlStateNormal];
        //                break;
        //            case 11:
        //                [label setTitle:@"$100万/200万" forState:UIControlStateNormal];
        //                break;
        //            default:
        //                break;
        //        }
		NSString *labeltitle = [NSString stringWithFormat:@"%lld/%lld",rs.sortedRoom[i].smallblind,2*rs.sortedRoom[i].smallblind];
		[label setTitle:labeltitle forState:UIControlStateNormal];
        [label setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [label setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
        [label addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        label.titleLabel.font=[UIFont boldSystemFontOfSize:15];
        
        [choumadaxiao addSubview:label];
    }
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSDictionary *dic=[[NSDictionary alloc]initWithObjectsAndKeys:@"0",@"zuowei",@"0",@"sudu",@"0",@"guibin",@"0",@"paizhuo",nil];
    [dic writeToFile:docPath atomically:YES];
    [dic release];
    
    if (scroll==nil) {
        scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(6, 72, 298, 112)];
        scroll.backgroundColor=[UIColor clearColor];
        scroll.contentSize=CGSizeMake(298*4, 112);
        scroll.delegate=self;
        //scroll.userInteractionEnabled=NO;
        scroll.showsHorizontalScrollIndicator=NO;
        [scroll.layer setCornerRadius:8.0f];
        scroll.pagingEnabled=YES;
        scroll.alwaysBounceHorizontal=NO;
    }
    [self.view addSubview:scroll];
    
    [self addButton];
    [self zuoweiPress];
    [self addChouMaDaXiao];
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
-(void)addChouMaDaXiao{
    if (choumadaxiao==nil) {
        choumadaxiao=[[UIScrollView alloc]initWithFrame:CGRectMake(11, 246, 286, 32)];
        choumadaxiao.backgroundColor=[UIColor clearColor];
        //choumadaxiao.contentSize=CGSizeMake(95*13, 32);
        choumadaxiao.delegate=self;
        choumadaxiao.decelerationRate=0.9;
        //choumadaxiao.pagingEnabled=YES;
        [choumadaxiao.layer setCornerRadius:6.0f];
        choumadaxiao.showsHorizontalScrollIndicator=NO;
        
    }
    [self.view addSubview:choumadaxiao];
    
    socketLogin = [[AppDelegate sharedDelegate] mainsocket];
	eventLogin = [[AppDelegate sharedDelegate] eventLogin];
	
	IMP OnReceiveRoomSort = [self methodForSelector:@selector(OnReceiveRoomSort:)];
	[eventLogin AddCmd:hhcSortedRoom fun:(CMDFUN)OnReceiveRoomSort];
	[eventLogin AddCmd:hchGetRoomSort fun:(CMDFUN)OnReceiveRoomSort];
    

}

- (void) OnReceiveRoomSort:(SocketEngine *)socket{
	
	NSLog(@"加载开始:");
}
-(void)click:(UIButton *)sender{
    
    int i=sender.tag;
    [choumadaxiao scrollRectToVisible:CGRectMake((i-1)*95, 0, 286, 31) animated:YES];
	[[AppDelegate sharedDelegate] cmdGetRoomList:socketLogin withRoomSort:i-1];
    
}
-(void)addButton{
    wuzuo=[UIButton buttonWithType:UIButtonTypeCustom];
    wuzuo.frame=CGRectMake(4, 6, 289, 32);
    [wuzuo addTarget:self action:@selector(wuzuoPre) forControlEvents:UIControlEventTouchUpInside];
    [wuzuo setImage:[UIImage imageNamed:@"五个座未点中.png"] forState:UIControlStateNormal];
    jiuzuo=[UIButton buttonWithType:UIButtonTypeCustom];
    jiuzuo.frame=CGRectMake(4, 41, 289, 32);
    [jiuzuo addTarget:self action:@selector(jiuzuoPre) forControlEvents:UIControlEventTouchUpInside];
    [jiuzuo setImage:[UIImage imageNamed:@"九个座未点中.png"] forState:UIControlStateNormal];
    renhezuo=[UIButton buttonWithType:UIButtonTypeCustom];
    renhezuo.frame=CGRectMake(4, 76, 289, 32);
    [renhezuo addTarget:self action:@selector(renhezuoPre) forControlEvents:UIControlEventTouchUpInside];
    [renhezuo setImage:[UIImage imageNamed:@"任何未点中.png"] forState:UIControlStateNormal];
    putongsu=[UIButton buttonWithType:UIButtonTypeCustom];
    putongsu.frame=CGRectMake(4+298, 6, 289, 32);
    [putongsu addTarget:self action:@selector(putongsuPre) forControlEvents:UIControlEventTouchUpInside];
    [putongsu setImage:[UIImage imageNamed:@"普通未点中.png"] forState:UIControlStateNormal];
    kuaisu=[UIButton buttonWithType:UIButtonTypeCustom];
    kuaisu.frame=CGRectMake(4+298, 41, 289, 32);
    [kuaisu addTarget:self action:@selector(kuaisuPre) forControlEvents:UIControlEventTouchUpInside];
    [kuaisu setImage:[UIImage imageNamed:@"快速未点中.png"] forState:UIControlStateNormal];
    renhesu=[UIButton buttonWithType:UIButtonTypeCustom];
    renhesu.frame=CGRectMake(4+298, 76, 289, 32);
    [renhesu addTarget:self action:@selector(renhesuPre) forControlEvents:UIControlEventTouchUpInside];
    [renhesu setImage:[UIImage imageNamed:@"任何未点中.png"] forState:UIControlStateNormal];
    noguibinzhuo=[UIButton buttonWithType:UIButtonTypeCustom];
    noguibinzhuo.frame=CGRectMake(4+298*2, 6, 289, 32);
    [noguibinzhuo addTarget:self action:@selector(noguibinzhuoPre) forControlEvents:UIControlEventTouchUpInside];
    [noguibinzhuo setImage:[UIImage imageNamed:@"不是贵宾未点中.png"] forState:UIControlStateNormal];
    guibinzhuo=[UIButton buttonWithType:UIButtonTypeCustom];
    guibinzhuo.frame=CGRectMake(4+298*2, 41, 289, 32);
    [guibinzhuo addTarget:self action:@selector(guibinzhuoPre) forControlEvents:UIControlEventTouchUpInside];
    [guibinzhuo setImage:[UIImage imageNamed:@"贵宾 未点中.png"] forState:UIControlStateNormal];
    renhezhuo=[UIButton buttonWithType:UIButtonTypeCustom];
    renhezhuo.frame=CGRectMake(4+298*2, 76, 289, 32);
    [renhezhuo addTarget:self action:@selector(renhezhuoPre) forControlEvents:UIControlEventTouchUpInside];
    [renhezhuo setImage:[UIImage imageNamed:@"任何未点中.png"] forState:UIControlStateNormal];
    yincang=[UIButton buttonWithType:UIButtonTypeCustom];
    yincang.frame=CGRectMake(4+298*3, 6, 289, 32);
    [yincang addTarget:self action:@selector(yincangPre) forControlEvents:UIControlEventTouchUpInside];
    [yincang setImage:[UIImage imageNamed:@"隐藏未点中.png"] forState:UIControlStateNormal];
    noyincang=[UIButton buttonWithType:UIButtonTypeCustom];
    noyincang.frame=CGRectMake(4+298*3, 41, 289, 32);
    [noyincang addTarget:self action:@selector(noyincangPre) forControlEvents:UIControlEventTouchUpInside];
    [noyincang setImage:[UIImage imageNamed:@"显示点中.png"] forState:UIControlStateNormal];
    [scroll addSubview:wuzuo];
    [scroll addSubview:jiuzuo];
    [scroll addSubview:renhezuo];
    [scroll addSubview:putongsu];
    [scroll addSubview:kuaisu];
    [scroll addSubview:renhesu];
    [scroll addSubview:noguibinzhuo];
    [scroll addSubview:guibinzhuo];
    [scroll addSubview:renhezhuo];
    [scroll addSubview:yincang];
    [scroll addSubview:noyincang];
}
- (void)viewDidUnload
{
    zuoweiBtn=nil;
    suduBtn=nil;
    guibinBtn=nil;
    yimanBtn=nil;
    scroll=nil;
    
    wuzuo=nil;
    jiuzuo=nil;
    renhezuo=nil;
    
    putongsu=nil;
    kuaisu=nil;
    renhesu=nil;
    
    
    noguibinzhuo=nil;
    guibinzhuo=nil;
    renhezhuo=nil;
    
    yincang=nil;
    noyincang=nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(IBAction)zuoweiPress{
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSDictionary *dic=[[NSDictionary alloc]initWithContentsOfFile:docPath];
    
    NSString *zuo=[dic objectForKey:@"zuowei"];
    switch ([zuo intValue]) {
        case 0:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位任何点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位五个座点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位九个座点中.png"] forState:UIControlStateNormal]; 
            break;
        default:
            break;
    }
    NSString *su=[dic objectForKey:@"sudu"];
    switch ([su intValue]) {
        case 0:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度任何未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度普通未点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度快速未点中.png"] forState:UIControlStateNormal]; 
            break;
        default:
            break;
    }
    NSString *yi=[dic objectForKey:@"yiman"];
    switch ([yi intValue]) {
        case 0:
            [yimanBtn setBackgroundImage:[UIImage imageNamed:@"已满牌座未隐藏未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [yimanBtn setBackgroundImage:[UIImage imageNamed:@"已满牌座隐藏未点中.png"] forState:UIControlStateNormal]; 
            break;
        
        default:
            break;
    }
    NSString *gui=[dic objectForKey:@"guibin"];
    switch ([gui intValue]) {
        case 0:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾任何未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾不是贵宾未点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾未点中.png"] forState:UIControlStateNormal]; 
            break;
            
        default:
            break;
    }
    
    [dic release];
    [scroll scrollRectToVisible:CGRectMake(0, 0, 298, 112) animated:YES];
    
}
-(IBAction)suduPress{
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSDictionary *dic=[[NSDictionary alloc]initWithContentsOfFile:docPath];
    
    NSString *zuo=[dic objectForKey:@"zuowei"];
    switch ([zuo intValue]) {
        case 0:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位任何未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位五个座未点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位九个座未点中.png"] forState:UIControlStateNormal]; 
            break;
        default:
            break;
    }
    NSString *su=[dic objectForKey:@"sudu"];
    switch ([su intValue]) {
        case 0:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度任何点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度普通点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度快速点中.png"] forState:UIControlStateNormal]; 
            break;
        default:
            break;
    }
    NSString *yi=[dic objectForKey:@"yiman"];
    switch ([yi intValue]) {
        case 0:
            [yimanBtn setBackgroundImage:[UIImage imageNamed:@"已满牌座未隐藏未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [yimanBtn setBackgroundImage:[UIImage imageNamed:@"已满牌座隐藏未点中.png"] forState:UIControlStateNormal]; 
            break;
            
        default:
            break;
    }
    NSString *gui=[dic objectForKey:@"guibin"];
    switch ([gui intValue]) {
        case 0:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾任何未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾不是贵宾未点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾未点中.png"] forState:UIControlStateNormal]; 
            break;
            
        default:
            break;
    }
    
    [dic release];
    [scroll scrollRectToVisible:CGRectMake(298, 0, 298, 112) animated:YES];
}
-(IBAction)guibinPress{
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSDictionary *dic=[[NSDictionary alloc]initWithContentsOfFile:docPath];
    
    NSString *zuo=[dic objectForKey:@"zuowei"];
    switch ([zuo intValue]) {
        case 0:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位任何未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位五个座未点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位九个座未点中.png"] forState:UIControlStateNormal]; 
            break;
        default:
            break;
    }
    NSString *su=[dic objectForKey:@"sudu"];
    switch ([su intValue]) {
        case 0:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度任何未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度普通未点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度快速未点中.png"] forState:UIControlStateNormal]; 
            break;
        default:
            break;
    }
    NSString *yi=[dic objectForKey:@"yiman"];
    switch ([yi intValue]) {
        case 0:
            [yimanBtn setBackgroundImage:[UIImage imageNamed:@"已满牌座未隐藏未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [yimanBtn setBackgroundImage:[UIImage imageNamed:@"已满牌座隐藏未点中.png"] forState:UIControlStateNormal]; 
            break;
            
        default:
            break;
    }
    NSString *gui=[dic objectForKey:@"guibin"];
    switch ([gui intValue]) {
        case 0:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾任何点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾不是贵宾点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾点中.png"] forState:UIControlStateNormal]; 
            break;
            
        default:
            break;
    }
    
    [dic release];
    [scroll scrollRectToVisible:CGRectMake(298*2, 0, 298, 112) animated:YES];
}
-(IBAction)yimanPress{
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSDictionary *dic=[[NSDictionary alloc]initWithContentsOfFile:docPath];
    
    NSString *zuo=[dic objectForKey:@"zuowei"];
    switch ([zuo intValue]) {
        case 0:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位任何未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位五个座未点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [zuoweiBtn setBackgroundImage:[UIImage imageNamed:@"座位九个座未点中.png"] forState:UIControlStateNormal]; 
            break;
        default:
            break;
    }
    NSString *su=[dic objectForKey:@"sudu"];
    switch ([su intValue]) {
        case 0:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度任何未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度普通未点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [suduBtn setBackgroundImage:[UIImage imageNamed:@"速度快速未点中.png"] forState:UIControlStateNormal]; 
            break;
        default:
            break;
    }
    NSString *yi=[dic objectForKey:@"yiman"];
    switch ([yi intValue]) {
        case 0:
            [yimanBtn setBackgroundImage:[UIImage imageNamed:@"已满牌座未隐藏点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [yimanBtn setBackgroundImage:[UIImage imageNamed:@"已满牌座隐藏点中.png"] forState:UIControlStateNormal]; 
            break;
            
        default:
            break;
    }
    NSString *gui=[dic objectForKey:@"guibin"];
    switch ([gui intValue]) {
        case 0:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾任何未点中.png"] forState:UIControlStateNormal];
            break;
        case 1:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾不是贵宾未点中.png"] forState:UIControlStateNormal]; 
            break;
        case 2:
            [guibinBtn setBackgroundImage:[UIImage imageNamed:@"贵宾未点中.png"] forState:UIControlStateNormal]; 
            break;
            
        default:
            break;
    }
    
    [dic release];
    [scroll scrollRectToVisible:CGRectMake(298*3, 0, 298, 112) animated:YES];
}

-(void)wuzuoPre{
    [wuzuo setImage:[UIImage imageNamed:@"五个座点中.png"] forState:UIControlStateNormal];
    [jiuzuo setImage:[UIImage imageNamed:@"九个座未点中.png"] forState:UIControlStateNormal];
    [renhezuo setImage:[UIImage imageNamed:@"任何未点中.png"] forState:UIControlStateNormal];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"1" forKey:@"zuowei"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self zuoweiPress];
    
    
}
-(void)jiuzuoPre{
    [wuzuo setImage:[UIImage imageNamed:@"五个座未点中.png"] forState:UIControlStateNormal];
    [jiuzuo setImage:[UIImage imageNamed:@"九个座点中.png"] forState:UIControlStateNormal];
    [renhezuo setImage:[UIImage imageNamed:@"任何未点中.png"] forState:UIControlStateNormal];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"2" forKey:@"zuowei"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self zuoweiPress];
}
-(void)renhezuoPre{
    [wuzuo setImage:[UIImage imageNamed:@"五个座未点中.png"] forState:UIControlStateNormal];
    [jiuzuo setImage:[UIImage imageNamed:@"九个座未点中.png"] forState:UIControlStateNormal];
    [renhezuo setImage:[UIImage imageNamed:@"任何点中.png"] forState:UIControlStateNormal];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"0" forKey:@"zuowei"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self zuoweiPress];
}
-(void)putongsuPre{
    [putongsu setImage:[UIImage imageNamed:@"普通点中.png"] forState:UIControlStateNormal];
    [kuaisu setImage:[UIImage imageNamed:@"快速未点中.png"] forState:UIControlStateNormal];
    [renhesu setImage:[UIImage imageNamed:@"任何未点中.png"] forState:UIControlStateNormal];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"1" forKey:@"sudu"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self suduPress];
}
-(void)kuaisuPre{
    [putongsu setImage:[UIImage imageNamed:@"普通未点中.png"] forState:UIControlStateNormal];
    [kuaisu setImage:[UIImage imageNamed:@"快速点中.png"] forState:UIControlStateNormal];
    [renhesu setImage:[UIImage imageNamed:@"任何未点中.png"] forState:UIControlStateNormal];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"2" forKey:@"sudu"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self suduPress];
}
-(void)renhesuPre{
    [putongsu setImage:[UIImage imageNamed:@"普通未点中.png"] forState:UIControlStateNormal];
    [kuaisu setImage:[UIImage imageNamed:@"快速未点中.png"] forState:UIControlStateNormal];
    [renhesu setImage:[UIImage imageNamed:@"任何点中.png"] forState:UIControlStateNormal];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"0" forKey:@"sudu"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self suduPress];
}
-(void)noguibinzhuoPre{
    [noguibinzhuo setImage:[UIImage imageNamed:@"不是贵宾点中.png"] forState:UIControlStateNormal];
    [guibinzhuo setImage:[UIImage imageNamed:@"贵宾 未点中.png"] forState:UIControlStateNormal];
    [renhezhuo setImage:[UIImage imageNamed:@"任何未点中.png"] forState:UIControlStateNormal];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"1" forKey:@"guibin"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self guibinPress];
}
-(void)guibinzhuoPre{
    [noguibinzhuo setImage:[UIImage imageNamed:@"不是贵宾未点中.png"] forState:UIControlStateNormal];
    [guibinzhuo setImage:[UIImage imageNamed:@"贵宾 点中.png"] forState:UIControlStateNormal];
    [renhezhuo setImage:[UIImage imageNamed:@"任何未点中.png"] forState:UIControlStateNormal];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"2" forKey:@"guibin"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self guibinPress];
}
-(void)renhezhuoPre{
    [noguibinzhuo setImage:[UIImage imageNamed:@"不是贵宾未点中.png"] forState:UIControlStateNormal];
    [guibinzhuo setImage:[UIImage imageNamed:@"贵宾 未点中.png"] forState:UIControlStateNormal];
    [renhezhuo setImage:[UIImage imageNamed:@"任何点中.png"] forState:UIControlStateNormal];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"0" forKey:@"guibin"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self guibinPress];
}
-(void)yincangPre{
    [yincang setImage:[UIImage imageNamed:@"隐藏点中.png"] forState:UIControlStateNormal];
    [noyincang setImage:[UIImage imageNamed:@"显示未点中.png"] forState:UIControlStateNormal];
   
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"1" forKey:@"yiman"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self yimanPress];
}
-(void)noyincangPre{
    [yincang setImage:[UIImage imageNamed:@"隐藏未点中.png"] forState:UIControlStateNormal];
    [noyincang setImage:[UIImage imageNamed:@"显示点中.png"] forState:UIControlStateNormal];
    
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory=[paths objectAtIndex:0];
	NSString* docPath=[documentsDirectory stringByAppendingPathComponent:[NSString stringWithString:@"PaiZhuoXuanXiang.plist"]];
    NSMutableDictionary *muldic=[[NSMutableDictionary alloc]initWithContentsOfFile:docPath];
    [muldic setObject:@"0" forKey:@"yiman"];
    [muldic writeToFile:docPath atomically:YES];
    [muldic release];
    [self yimanPress];
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
     //scrollView.userInteractionEnabled=NO;
}                           // called on start of dragging (may require some time and or distance to move)
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    //scrollView.userInteractionEnabled=YES;
}
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
    //scrollView.userInteractionEnabled=NO;
} // called on finger up as we are moving
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    
    if (scrollView==choumadaxiao) {
        int i=scrollView.contentOffset.x/94;
        [scrollView scrollRectToVisible:CGRectMake(i*95, 0, 286, 31) animated:YES];
        [[AppDelegate sharedDelegate] cmdGetRoomList:socketLogin withRoomSort:i];

    }
    else{
        float f=scroll.contentOffset.x;
        int i=f/298;
        
        switch (i) {
            case 0:
                [self zuoweiPress];
                break;
            case 1:
                [self suduPress];
                break;
            case 2:
                [self guibinPress];
                break;
            case 3:
                [self yimanPress];
                break;
                
            default:
                break;
        }
        }
    
    
}
@end
